all:
	$(MAKE) linux
	
win32:
	del *.dll
	$(MAKE) go CC='gcc' FLAGS='-O3 -Wall' SPE_FLAG='-Wl' EXT='.dll'
	strip libtd_bdd.dll

cross-win:
	rm -f *.dll
	$(MAKE) go CC='cross-gcc' FLAGS='-O3 -Wall' SPE_FLAG='-Wl' EXT='.dll'
	cross-strip libtd_bdd.dll

linux:
	rm -f *.so
	$(MAKE) go CC='gcc' FLAGS='-O3 -fPIC -Wall' SPE_FLAG='-Wl,-soname,libtd_bdd.so' EXT='.so'

bsd:
	rm -f *.so
	$(MAKE) go CC='gcc' FLAGS='-O3 -fPIC -Wall' SPE_FLAG='-Wl,-soname,libtd_bdd.so' EXT='.so'

solaris:
	rm -f *.so
	+$(MAKE) go CC='gcc' FLAGS='-O3 -fPIC -Wall' SPE_FLAG='-G -B dynamic' EXT='.so'

darwin:
	rm -f *.so
	$(MAKE) go CC='gcc' FLAGS='-O3 -Wall -fno-common' SPE_FLAG='-dynamiclib' EXT='.dylib'

dist:
	rm -f *.so
	+$(MAKE) go CC='distcc' FLAGS='-O3 -fPIC -Wall' SPE_FLAG='-Wl,-soname,libtd_bdd.so' EXT='.so'


go:
	+$(MAKE) add.o del.o get.o read_write.o update.o routines.o make_td.o  
	+$(MAKE) td_div.o td_select.o td_add.o td_del.o td_update.o 
	+$(MAKE) td_error.o td_open_close.o crc32.o
	
	$(CC) -O3 -Wall -shared $(SPE_FLAG) -o libtd_bdd$(EXT) add.o get.o read_write.o update.o routines.o del.o td_select.o td_div.o td_open_close.o td_add.o td_del.o td_update.o td_error.o make_td.o crc32.o



add.o: bdd.h add.c
	$(CC) -c add.c $(FLAGS)

del.o: bdd.h del.c
	$(CC) -c del.c $(FLAGS)

get.o: bdd.h get.c
	$(CC) -c get.c $(FLAGS)

update.o: bdd.h update.c
	$(CC) -c update.c $(FLAGS)

td_select.o: bdd.h td_select.c
	$(CC) -c td_select.c $(FLAGS)

make_td.o: bdd.h make_td.c
	$(CC) -c make_td.c $(FLAGS)

read_write.o: bdd.h read_write.c
	$(CC) -c read_write.c $(FLAGS)
	
routines.o: bdd.h routines.c
	$(CC) -c routines.c $(FLAGS)
	
td_div.o: bdd.h td_div.c
	$(CC) -c td_div.c $(FLAGS)
	
td_add.o: bdd.h td_add.c
	$(CC) -c td_add.c $(FLAGS)

td_del.o: bdd.h td_del.c
	$(CC) -c td_del.c $(FLAGS)

td_update.o: bdd.h td_update.c
	$(CC) -c td_update.c $(FLAGS)
	
td_error.o: bdd.h td_error.c
	$(CC) -c td_error.c $(FLAGS)

td_open_close.o: bdd.h td_open_close.c
	$(CC) -c td_open_close.c $(FLAGS)

crc32.o: crc32.h crc32.c
	$(CC) -c crc32.c $(FLAGS)

clean:
	rm -rf *.o
	rm -rf *~
